/* //拉弓机制修改
LivingEntityUseItemEvent.addListener(LivingEntityUseItemEvent.Start, event => {
    if (event.getItem().item instanceof $BowItem && event.entity instanceof $Player) {
        event.entity.forgePersistentData.putFloat("BowChargeTime", 0)
    }
})
LivingEntityUseItemEvent.addListener(LivingEntityUseItemEvent.Tick, event => {
    if (event.getItem().item instanceof $BowItem && event.entity instanceof $Player) {

        if (event.entity.forgePersistentData.contains("BowChargeTime") && event.entity.forgePersistentData.getFloat("BowChargeTime") < 20) {

            event.entity.forgePersistentData.putFloat("BowChargeTime", event.entity.forgePersistentData.getFloat("BowChargeTime") + 1.00 * 3)
            event.duration = event.item.getUseDuration() - event.entity.forgePersistentData.getFloat("BowChargeTime")
            if (event.entity.forgePersistentData.getFloat("BowChargeTime") > 20) {
                event.entity.releaseUsingItem()
            }
        }
    }
})
LivingEntityUseItemEvent.addListener(LivingEntityUseItemEvent.Stop, event => {
    if (event.getItem().item instanceof $BowItem && event.entity instanceof $Player) {
        if (event.entity.forgePersistentData.contains("BowChargeTime") && $BowItem.getPowerForTime(event.entity.forgePersistentData.getFloat("BowChargeTime")) > 0.1) {
            if (event.entity instanceof $ServerPlayer) {
                new waitRunable(2, () => { event.item.releaseUsing(event.entity.level, event.entity, event.getDuration()) })
                new waitRunable(4, () => { event.item.releaseUsing(event.entity.level, event.entity, event.getDuration()) })
            }
        }
    }
}) */
//攻击机制修改玩家快速点击攻击键时（攻击强度 < 0.5），攻击会被取消，无法造成伤害。只有当玩家等待攻击充能到至少一半（强度≥0.5）后再攻击，才能成功造成伤害。例外：持有 "迷你枪" 时不受此限制，可以正常快速攻击。
LivingAttackEvent.addListener(event => {
    if (event.source.msgId == "player" && event.source.player.mainHandItem.getItem() != Item.of('pneumaticcraft:minigun')) {
        if (event.source.player.getAttackStrengthScale(0) < 0.5) {
            event.setCanceled(true)
        }
    }
})